﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<skags.Models.PageViewModel>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Síður
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<div id="main">
    <h2>Síður</h2>
    <table>
        <tr>
            <td><a href="/Admin/CreatePage"><img src="../../Content/icons/create.png" alt="Ný síða" /></a></td>
            <th>
                ID
            </th>
            <th>
                Titill
            </th>
            <th>
                Flokkur
            </th>
            <th>
                Höfundur
            </th>
            <th>
                Búin til
            </th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
                <a href="/Admin/CreatePage/<%= item.ID %>"><img src="../../Content/icons/create.png" alt="Ný undirsíða" /></a>
                &nbsp;
                <a href="/Admin/DeletePage/<%= item.ID %>" onclick="return confirm('Ertu viss um að þú viljir eyða þessari síðu og öllum undirsíðum?')"><img src="../../Content/icons/delete.png" alt="Eyða" /></a>
                &nbsp;
                <a href="/Admin/EditPage/<%= item.ID %>"><img src="../../Content/icons/edit.png" alt="Breyta" /></a>
            </td>
            <td>
                <%: item.ID %>
            </td>
            <td>
                <b><%: item.Title %></b>
            </td>
            <td>
                <%: item.ParentName %>
            </td>
            <td>
                <%: item.CreatorName %>
            </td>
             <td>
                <%: String.Format("{0:g}", item.DateCreated) %>
            </td>
        </tr>
        <% foreach (var subitem in item.SubPages) { %>
    
        <tr>
            <td>
                <a href="/Admin/DeletePage/<%= subitem.ID %>" onclick="return confirm('Ertu viss um að þú viljir eyða þessari undirsíðu?')"><img src="../../Content/icons/delete.png" alt="Eyða" /></a>
                &nbsp;
                <a href="/Admin/EditPage/<%= subitem.ID %>"><img src="../../Content/icons/edit.png" alt="Breyta" /></a>
            </td>
            <td>
                <%: subitem.ID %>
            </td>
            <td>
                <%: subitem.Title %>
            </td>
            <td>
                <%: subitem.ParentName %>
            </td>
            <td>
                <%: subitem.CreatorName %>
            </td>
             <td>
                <%: String.Format("{0:g}", item.DateCreated) %>
            </td>
        </tr>
    <% } %>
    <% } %>

    </table>
</div>
</asp:Content>
